<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="../perEvaluationResult/importhead.jsp" %>
<%@ page import="java.text.*"%>
<% 
	String username = request.getParameter("username");
	String stuid=request.getParameter("stuid");
	List <VCheckReport> checkreprots = DAOFactory.getCheckReportDAO().getReportsByUsername(username);
	VStudent student=null;
	if(stuid!=null){
		 student= DAOFactory.getStudentDAO().getVStudent(Integer.parseInt(stuid));
	}
	
	request.setAttribute("student",student);
	for(int i=0;i<checkreprots.size();i++){
		VCheckReport report = (VCheckReport)checkreprots.get(i);
		if(report.getChecktypeid() == 1){
			request.setAttribute("epq", report);
			//从epq中提取评测项列表
			List<TCheckReportItem> list = DAOFactory.getCheckReoprtItemDAO().getCheckReportItemsByCheckID(report.getCheckid());
			request.setAttribute("epqlist", list);
		}else if(report.getChecktypeid() == 2){
			request.setAttribute("mht", report);
			//从mht中提取评测项列表
			List<TCheckReportItem> list = DAOFactory.getCheckReoprtItemDAO().getCheckReportItemsByCheckID(report.getCheckid());
			request.setAttribute("mhtlist", list);
		}
	}
	
	if(request.getAttribute("epq")==null){
		request.setAttribute("epq", new VCheckReport());
		request.setAttribute("epqlist", null);
	}if(request.getAttribute("mht")==null){
		request.setAttribute("mht", new VCheckReport());
		request.setAttribute("mhtlist", null);
	}
	
	VCheckReport titlereport = new VCheckReport();
	String checkdate = "";
	for(int i=0; i<checkreprots.size(); i++){
		titlereport = (VCheckReport)checkreprots.get(i);
		Format f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date d = (Date)f.parseObject(titlereport.getChecktime());
		Format f2 = new SimpleDateFormat("yyyyMMdd");
		checkdate = f2.format(d);
		break ;
	}
 %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="../js/jsuntil/FileSaver.js"></script>
    <script src="../js/jsuntil/jquery.wordexport.js"></script>
    <style>
        body{
            font-family: 宋体;
            font-size: 12px;
            padding-bottom:30px;
        }
        table,tr,td{
            padding: 0;
            height: 38px;
            line-height:20px;
        }
        .weidu{
            margin-top: 20px;
        }
        
        .MsoNormalTable{
            mso-style-name:普通表格;
            mso-style-parent:"";
            mso-style-noshow:yes;
            mso-tstyle-rowband-size:0;
            mso-tstyle-colband-size:0;
            mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt;
            mso-para-margin:0pt;
            mso-para-margin-bottom:.0001pt;
            mso-pagination:widow-orphan;
            font-family:'Times New Roman';
            font-size:10.0000pt;
            mso-ansi-language:#0400;
            mso-fareast-language:#0400;
            mso-bidi-language:#0400;
        }
    </style>
</head>
<body>
    <input type="button" value="保存为Word" onclick="toWord();">
    <div id="export_word" style="margin:auto;width:90%;">
        <div style="text-align:center;height:30px;line-height:30px;">
                <h2>学生心理健康档案</h2> 
        </div> 
        <div>
                <h4>1.基本情况</h4>
        </div>
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td width="10%">姓名</td>
                    <td width="15%">${student.realName }</td>
                    <td width="10%">班级</td>
                    <td width="15%">${student.gradename }${student.className }</td>
                    <td width="10%">性别</td>
                    <td width="15%">${student.sex }</td>
                    <td width="10%">出生年月日</td>
                    <td width="15%">${student.birthday }</td>
                </tr>
                <tr>
                    <td>民族</td>
                    <td></td>
                    <td>籍贯</td>
                    <td></td>
                    <td>血型</td>
                    <td></td>
                    <td>健康状况</td>
                    <td></td>
                </tr>
                <tr>
                    <td colspan="2">家庭住址</td>
                    <td colspan="6"></td>
                </tr>
                <tr>
                    <td colspan="2">寄住地址</td>
                    <td colspan="2"></td>
                    <td colspan="2">生理缺陷</td>
                    <td colspan="2"></td>
                </tr>
                <tr>
                    <td colspan="2">兴趣与特长</td>
                    <td colspan="2"></td>
                    <td colspan="2">个人病史</td>
                    <td colspan="2"></td>
                </tr>
            </table>
        </div>
        <div>
                <h4>2.家庭情况</h4>
        </div>
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td rowspan="2">称谓</td>
                    <td rowspan="2">姓名</td>
                    <td rowspan="2">年龄</td>
                    <td rowspan="2">学历</td>
                    <td rowspan="2">职业</td>
                    <td rowspan="2">爱好与特长</td>
                    <td rowspan="2">个性特点</td>
                    <td colspan="4">你对他（她）的喜爱程度</td>
                </tr>
                <tr>
                    <td>喜爱</td>
                    <td>较喜爱</td>
                    <td>无所谓</td>
                    <td>不喜爱</td>
                </tr>
                <tr>
                    <td>父亲</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>母亲</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>继父</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>继母</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>养父</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>养母</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td colspan="3">是否是独生子女</td>
                    <td colspan="8" style="text-align: right">（填“是”或“否”）</td>
                </tr>
                <tr>
                    <td colspan="3">居住环境</td>
                    <td colspan="8">
                        很好（ ）较好（ ）一般（ ）差（ ）
                    </td>
                </tr>
                <tr>
                    <td colspan="3">家庭氛围</td>
                    <td colspan="8">
                        很好（ ）较好（ ）一般（ ）差（ ）
                    </td>
                </tr>
            </table>
        </div>
        <div>
                <h4>3.学习经历</h4>
        </div>
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td rowspan="2">起止时间</td>
                    <td rowspan="2">在何校学习</td>
                    <td rowspan="2">担任职务</td>
                    <td colspan="5">
                        对当时所处集体的喜爱程度
                    </td>
                </tr>
                <tr>
                    <td>喜欢</td>
                    <td>较喜欢</td>
                    <td>一般</td>
                    <td>不太喜欢</td>
                    <td>不喜欢</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
        <div>
            <h4>4.自我评价</h4>
        </div>
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td width="25%"></td>
                    <td width="15%">很好</td>
                    <td width="15%">较好</td>
                    <td width="15%">一般</td>
                    <td width="15%">较差</td>
                    <td width="15%">很差</td>
                </tr>
                <tr>
                    <td>人际关系</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>学习成绩</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>学习态度</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>学习习惯</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>思想品德</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>行为习惯</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>身体状况</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>自控能力</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>体育运动</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>获奖情况</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td rowspan="6">
                        影响学生个人生活的重大事件
                    </td>
                    <td colspan="2">
                        家庭成员死亡
                    </td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        父母离异
                    </td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        与教师、同学关系紧张
                    </td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        生活条件改变
                    </td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        影响生活的重大挫折
                    </td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        其它
                    </td>
                    <td colspan="3"></td>
                </tr>
            </table>
        </div>
        
        <div>
            <h4>5.困惑与烦恼</h4>
        </div>
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </div>
        <div>
            <h6>
                备注：“影响学生个人生活的重大事件”有就如实填写，没有就填“无”；“困惑与烦恼”包括如下几点1、“学习很努力，成绩不理想”；2“父母限制和伙伴交往游玩”；3“人际关系紧张”；4“没有知心朋友”；5“父母有时批评或骂自己，整天唠叨个不停”；7“无缘无故被被人取笑欺负”；8“身为班干部，管那些有错的同学，有时他们不但不停还说三道四”；9“犯了错误，有时父母不耐心的开导批评，非打即骂；10、同学不尊重自己，给自己起错号”等等。每个同学的烦恼和困惑是不同的，也不是上述十点全包括。
            </h6>
        </div>
        <div style="text-align:center;height:30px;line-height:30px;">
            <h2>心理健康状况分析（MHT）</h2> 
        </div> 
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td style="width:20%">施测次数</td>
                    <td style="width:40%" colspan="3">第一次施测</td>
                    <td style="width:40%;" colspan="3">第二次施测</td>
                </tr>
                <tr>
                    <td>施测时间</td>
                    <td colspan="3">${mht.checktime }</td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td>因素分析</td>
                    <td>原始分</td>
                    <td>标准分</td>
                    <td>分析</td>
                    <td>原始分</td>
                    <td>标准分</td>
                    <td>分析</td>
                </tr>
             <c:if test="${mhtlist != null }">
             <c:forEach items="${mhtlist}" var="obj">
             	<tr>
                    <td>${obj.itemname }</td>
                    <td>${obj.originalscore }</td>
                    <td>${obj.standardscore }</td>
                    <td>${obj.status }</td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
             </c:forEach>
             </c:if>
             <c:if test="${mhtlist == null }">
                
                <tr>
                    <td>学习焦虑</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>对人焦虑</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>孤独倾向</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>自责倾向</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>过敏倾向</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>身体症状</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>恐怖倾向</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>冲动倾向</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>合计</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>效度量表</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
              </c:if>
              
              <% 
              	String resultintro = "",suggestion=""; 
              	List list1 = (List)request.getAttribute("mhtlist");
              	
             	if(list1!=null && list1.size()>0){
	              	for(int i=0;i<list1.size();i++){
	              		TCheckReportItem item = (TCheckReportItem)list1.get(i);
	              		resultintro += item.getResultintro()+",";
	              		suggestion += item.getSuggestion() +",";
	              	}
	              } 
              %>
              
                <tr style="height:200px;">
                    <td>个性特征分析</td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                    <%=resultintro %><br><br>
                        签定人：
                    </td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                    <br><br>
                        签定人：
                    </td>
                </tr>
                <tr style="height:200px;">
                    <td>教育建议</td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                        <%=suggestion %>
                    </td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                        
                    </td>
                </tr>
            </table>
        </div>

        <div style="text-align:center;height:30px;line-height:30px;">
            <h2>个性特征分析（EPQ）</h2> 
        </div> 
        <div>
            <table style="text-align: center; border-collapse:collapse;width:100%;mso-table-layout-alt:fixed;border:none;mso-border-left-alt:0.5000pt solid windowtext;mso-border-top-alt:0.5000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;mso-border-bottom-alt:0.5000pt solid windowtext;mso-border-insideh:0.5000pt solid windowtext;mso-border-insidev:0.5000pt solid windowtext;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" class="MsoNormalTable" border="1">
                <tr>
                    <td style="width:20%">施测次数</td>
                    <td style="width:40%" colspan="3">第一次施测</td>
                    <td style="width:40%;" colspan="3">第二次施测</td>
                </tr>
                <tr>
                    <td>施测时间</td>
                    <td colspan="3">${epq.checktime }</td>
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td>分量表名称</td>
                    <td>原始分</td>
                    <td>T分</td>
                    <td>分析</td>
                    <td>原始分</td>
                    <td>T分</td>
                    <td>分析</td>
                </tr>
            <c:if test="${epqlist != null }">
             <c:forEach items="${epqlist}" var="obj">
             	<tr>
                    <td>${obj.itemname }</td>
                    <td>${obj.originalscore }</td>
                    <td>${obj.standardscore }</td>
                    <td>${obj.status }</td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
             </c:forEach>
             </c:if>
             <c:if test="${epqlist == null }">
                <tr>
                    <td>P（精神质）</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>E（内外倾）</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>N（情绪性）</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>L（掩饰性）</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
               </c:if> 
               <% 
              	String resultintro2 = "",suggestion2=""; 
              	List list2 = (List)request.getAttribute("epqlist");
            	
              	if(list2!=null && list2.size()>0){
	              	for(int i=0;i<list2.size();i++){
	              		TCheckReportItem item = (TCheckReportItem)list2.get(i);
	              		resultintro2 += item.getResultintro()+",";
	              		suggestion2 += item.getSuggestion() +",";
	              	}
              	} 
              %>
                <tr style="height:200px;">
                    <td>个性特征分析</td>
                    <td colspan="3" style="vertical-align:bottom">
                    <%= resultintro2%><br><br>
                        签定人：
                    </td>
                    <td colspan="3" style="vertical-align:bottom">
                    <br><br>
                        签定人：
                    </td>
                </tr>
                <tr style="height:200px;">
                    <td>教育建议</td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                        <%=suggestion2 %>
                    </td>
                    <td colspan="3" style="vertical-align:bottom; text-align:left">
                        
                    </td>
                </tr>
            </table>
        </div>
    </div>
</body>
<script>
    function toWord(){
        $("#export_word").wordExport("学生心理健康档案-"+"<%=titlereport.getRealName()%>" + "_"+"<%=checkdate%>");
    }
    
    $(function () {
		$('tr[style!="height:200px;"]').css('height',38);
	})
</script>
</html>